<%@ page language="java" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<%@ include file="/commons/jsp/taglibs.jsp"%>
<%@taglib uri="http://www.framework.com/taglib" prefix="frame"%>
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />
<script type="text/javascript" src="${ctx}/commons/js/uploadify/jquery.uploadify.min.js"></script>
<link type="text/css" href="${ctx}/commons/js/uploadify/uploadify.css" rel="stylesheet"></link>
  <body>
    <div class="easyui-layout" data-options="fit:true,border:false" >
            <div data-options="region:'north',title:'有效投标人列表',split:true" style="height:150px;">
	             <table id="listProjectsBidTable" class="easyui-datagrid" 
					data-options="singleSelect:false,toolbar:'#goodstb',method:'post',rownumbers:true,fitColumns:true,border:true,
						pagination:false,multiSort:true,remoteSort:true,striped:true,onLoadSuccess:function(data){$('#'+projectsParamObj.searchID).attr('disabled',false); selectRow(data);},
						url:'${ctx}/business/projectmanage/bizmanager/findValidBidInfo?id=${projectId}'">
					<thead>
						<tr>
						    <th data-options="field:'id',checkbox:true"></th>
							<th data-options="field:'bidderName',width:80,title:'投标单位',sortable:true" align="center"></th>
							<th data-options="field:'bidAmount',width:50,title:'报价金额(${project.bidType==0 ?'元':'%'})',sortable:true" align="center"></th>
							<th data-options="field:'bidTime',width:80,title:'投标时间',sortable:true,formatter:function(value,row,index){return value+'.'+row.millisecond}" align="center"></th>
							<th data-options="field:'evalutionResult',width:60,formatter: function(value,row,index){if(value==1){return '通过';}else if(value==2){return '无效标';}else if(value==3){return '无需评审';}else{{return '未评';}}},title:'状态',sortable:true" align="center"></th>
							<th data-options="field:'operation',width:150,title:'操作',formatter:getOptionsBtn" align="center" ></th>
					</tr>
					</thead>
				</table>
            </div>   
			 <div data-options="region:'center',title:'变更'" style="height:100px;border:0px">  
			 <%--<input type="hidden" name="bidInfoId" id="bidInfoId" value="${bidInfoId}">--%>
			 <input type="hidden" id="isBid" name="isBid" value="${isBid}" />
			   <form id="myform" method="post">
				  <table class="infoTable">
					<tbody>
					    <tr >
					        <th align='center' width="15%">变更理由</th>
						    <td colspan="2">
						        <input type="hidden" name="newBidderId" value="" id="newBidderId">
						        <input type="hidden" name="projectId" value="" id="projectId">
						        <input type="hidden" name="newBidderName" value="" id="newBidderName">
						        <input type="hidden" name="budgetMenuData" id="budgetMenuData" value=""/>

								<textarea name="changeReason" id="changeReason"  style="height:70px; width:450px;" oninput="checkLength('changeReasonError',200,'changeReason')" onpropertychange="checkLength('changeReasonError',200,'changeReason')" onkeyup="checkLength('changeReasonError',200,'changeReason')"  class="easyui-validatebox"  data-options="required:true,validType:'isBlank'"></textarea>
							    <font color="red"><br />注：200个字符以内，还可以输入<span class="input_font" id="changeReasonError">200</span>个字符</font>
							</td>
					    </tr>
						<tr>
							<th  align='center' width="15%">上传附件</th>

							<td style="border-right: none" width="35%">
				               <div id="fileQueue" style="margin: 10px 0px 0px 10px">
							           <input type="file" name="uploadify" id="uploadify" data-options="required:true"/>
							           <p style="color: #aaaaaa;width: auto"> 
                                                                                       可上传jpg,png,gif,bmp,pdf,zip,rar类型文件<br/>
				                       </p>
				                </div>
			                 </td>
							<td style="border-left: none" colspan="2">
							<!--<c:forEach items="${resList}" var="res">
									<c:if test="${res.functionFlog==25}">
										<div><a class="easyui-linkbutton" href="javascript:showOpenFile('${ctx }','${res.id}',requestUrl);">${res.oldName}</a> <span style="cursor: pointer;" onclick="deleteFile(this,'${res.id}');"><img src="${ctx }/commons/themes/icons/cancel.png"/></span></div>
									</c:if>
								</c:forEach>  -->	
							</td>
						</tr>
					  </tbody>
				    </table>
				   </form>
		     </div> 
		    
		</div>
	</div>
	<div id="bindPicDialog"></div>
	<div id="selPicDialog"></div>
	<div id="noCompetReasonDialog"></div>
</body>
	<script type="text/javascript">
		//初始化表格对应的js对象
		var projectsParamObj;
		$(function() {
			//初始化表格对象数据
			projectsParamObj = new initParams(
					{
						paramObjName : 'projectsParamObj',//表格对应的实体对象名称，好区分多个表格情况下的对象
						tableId:'listProjectsTable',
						addDataFormId:'addProjectsDataForm',
						showDialogId:'firstLevelDialog',
						searchID:'searchProjects',
						resetSearchID:'resetsearchProjects',
						searchFormID:'searchProjectsForm',
						updateUrl:"${ctx}/business/projectmanage/input?projectId=",
						deleteUrl:'${ctx}/business/projectmanage/remove',
						addDialogWidth:800,
						addDialogHeight:600,
						ctx:'${ctx}',
						addDialogTitle:'采购项目信息'
					});
			//初始化查询
			init(projectsParamObj);
			
			var resIds = "";
			<c:forEach items="${resList}" var="res">
			resIds += ",${res.id}";
			</c:forEach>
			$('#budgetMenuData').val(resIds);
			$("#uploadify").uploadify({
				'height'        : 27,   
	            'width'         : 80,    
	            'buttonText'    : '选择附件',
	            'queueID': 'fileQueue',//队列的ID
	            'queueSizeLimit':5,// 附件附列长度
				'swf': '${ctx}/commons/js/uploadify/uploadify.swf',
				'uploader':'${ctx}/business/projectmanage/upload;jsessionid=${pageContext.session.id}?functionFlog=26',// 上传时请求的后台处理的controller
				'cancelImg': '${ctx}/commons/js/uploadify/uploadify-cancel.png',
				'method':'post',  
				'folder': '',
				'preventCaching' : true,
				'fileTypeExts' :'*.jpg;*.png;*.gif;*.bmp;*.pdf;*.zip;*.rar;',
				'auto': true,
				'multi': false,//是否可多选
				'removeCompleted' : false,
				'successTimeout' : 55555,
				'onUploadSuccess':function(file, data, response){
					$('#' + file.id).find('.data').html(' 上传完毕');
					$('#budgetMenuData').val("," + data);
					var cancel=$('#fileQueue .uploadify-queue-item[id="' + file.id + '"]').find(".cancel a");
					$('#fileQueue .uploadify-queue-item[id!="' + file.id + '"]').html("");
					if (cancel) {
					   cancel.attr("rel", data);
					   cancel.click(function () {
						   var cancelData = cancel.attr("rel");
			               var  budgetMenuData = $('#budgetMenuData').val();
			               var index = budgetMenuData.indexOf(","+cancel.attr("rel"))
			               if(index != -1){
			            	   budgetMenuData = budgetMenuData.replace(","+cancelData,"");
			            	   $('#budgetMenuData').val(budgetMenuData);
			               }
					   });
					}
				},
				'onSelectError':function(file, errorCode, errorMsg){
					switch(errorCode) {
						case -110:
							//this.queueData.errorMsg="文件 ["+file.name+"] 大小超出系统限制的"+$('#file_upload').uploadify('settings','fileSizeLimit')+"大小！";
							this.queueData.errorMsg='所选文件大小超出系统限制!';
							break;
						case -120:
							//this.queueData.errorMsg="文件 ["+file.name+"] 大小异常！"
							this.queueData.errorMsg='所选文件大小异常!';
							break;
						case -130:
							//this.queueData.errorMsg="文件 ["+file.name+"] 类型不正确！"
							this.queueData.errorMsg='所选文件类型不正确!';
							break;
					}
				},
				'onCancel' : function(file){
					alert(file);
				},
				onClose : function(){// 解决IE浏览器中无法移除object标签，导致上传插件的flash无法使用，所有的dialog都会出现问题
					top.$("#uploadify").uploadify('destroy');//销毁文件上传对象....
					top.$("#dealDeclareUpload").uploadify('destroy');//销毁文件上传对象....
					top.$("#uploadify").uploadify('destroy');//销毁文件上传对象....
					if(top.$('#'+paramObj.showDialogId).find("object").length > 0){
						var fileQueue = top.window.document.getElementById("fileQueue");
						fileQueue.innerHTML = "";
						fileQueue.parentNode.removeChild(fileQueue);
					}
					afterClosed();
				}
			});
		});
		function deleteFile(v,resId){
			var parent = v.parentNode;
			parent.parentNode.removeChild(parent);
			var  budgetMenuData = $('#budgetMenuData').val();
	        var index = budgetMenuData.indexOf(","+resId)
	        if(index != -1){
	     	   budgetMenuData = budgetMenuData.replace(","+resId,"");
	     	   $('#budgetMenuData').val(budgetMenuData);
	        }
		}
		
		/**
		 * 操作按钮处理
		 * @param {Object} value
		 * @param {Object} row
		 * @param {Object} index
		 */
		function getOptionsBtn(value, row, index){
			var btnsHtml = "<span class='optionBtnsArea'>";
			var infoViewHtml = '<a href="javascript:void(0)" onclick="getProjectDetail(\'' + row.id + '\')" class="">详情</a>&nbsp;';
			btnsHtml+=infoViewHtml; 
			return btnsHtml +"</span>";
		}

		
		
		/**
		*投标详情
		*/
		function getProjectDetail(id){
			top.$('#secondtLevelDialog').dialog({    
			    title:"投标详情",  
			    iconCls:'icon-view',
			    width: 1000,    
			    height: 580,    
			    closed: false,    
			    inline : true,
			    cache: false,    
			    href: "${ctx}/business/projectmanage/getBidDetail?id=" + id,
			    modal: true,
				extractor : function(data){
					if($.trim(data) == "unLogin"){
						var msn = ''||i18n[''];
						msn = msn||i18n[data];
						if(msn != undefined){
							top.$.messager.alert('提示',msn,'info',function(){top.location='ctx/manage';});
							return '';
						}
					}
					return data;
				},
			    buttons : [{
						text:projectsParamObj.cancelButton,
						iconCls:'icon-cancel',
						handler:function(){
							top.$('#secondtLevelDialog').dialog('close');
						}}]
			});
			top.$('#'+projectsParamObj.showDialogId).dialog("center");
		}
	
		/** 列表loadsuccess后默认选中中标人信息**/
		function selectRow(data){
			  var rowData = data.rows;    
			    $.each(rowData,function(index,row){//遍历JSON     
			        if(row.isMultHit==true){ //如果数据行为已选中则选中改行
			            $("#listProjectsBidTable").datagrid("selectRow", index);  
			        }  
			           
			    });  
		}
    
			
</script>